﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using Minecraft.Config.Csv.CsvCom;
using Minecraft.Model;

namespace Minecraft.Config.Csv.CsvCls
{
	public partial class Mod_Items
	{
		/// <summary>
		/// 背包物品格子放置数量上限
		/// </summary>
		public int Max_num_Convert
		{
			get
			{
				int.TryParse(Max_num, out int maxNum);
				return maxNum;
			}
		}
		public EnumGoodsType enumGoodsType_Convert
		{
			get
			{
				return (EnumGoodsType)Convert.ToInt32(Type);
			}
		}
		/// <summary>
		/// 类型
		/// </summary>
		public int Type_Convert
		{
			get
			{
				return int.Parse(Type);
			}
		}

		/// <summary>
		/// 物品的属性以及对应的属性值（依赖属性表）
		/// </summary>
		public ModAttributeInfo modAttributeInfo_Convert
		{
			get
			{
				var attrs = Attribute.Split(new char[] { '#' }, StringSplitOptions.RemoveEmptyEntries);
				if (attrs.Length == 2)
				{
					return new ModAttributeInfo
					{
						Id = int.Parse(attrs[0]),
						//AttributeName = CsvConfig.attributeList.FirstOrDefault(m => m.Id == attrs[0]).Attribute_name,
						AttributeName = CsvConfig.GetMod_AttributeInfoById(attrs[0]).Attribute_name,
						Value = int.Parse(attrs[1]),
					};
				}
				else
				{
					return new ModAttributeInfo
					{
						Id = -1,
						AttributeName = "未知",
						Value = -1
					};
				}
			}
		}
	}
}
